from lib.webui_permission import  *
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from hyrobot.common import CHECK_POINT, STEP

class c73303ch:
    name = '验证弹出"登出""修改密码"功能-c73303ch' # 测试用例名字
    # driver = webdriver.Firefox()
# 初始化方法
    def setup(self):
        STEP(1, '登陆网站')
        driver = open_browser()
        user_login(driver)

    #清除方法
    def teardown(self):
        driver = get_global_webdriver()
        driver.quit()

    # 测试用例步骤
    def teststeps(self):
        # 获取webdriver对象 对应 已经登录好的浏览器
        driver = get_global_webdriver()
        time.sleep(3)
        # .avatar - wrapper > span
        driver.find_element(By.CSS_SELECTOR, ".avatar-wrapper > span:nth-child(1)").click()
        time.sleep(3)
        got_change_psw = driver.find_element(By.CSS_SELECTOR,"li.el-dropdown-menu__item:nth-child(1) > span:nth-child(1)").text
        got_logout = driver.find_element(By.CSS_SELECTOR,"li.el-dropdown-menu__item:nth-child(2) > span:nth-child(1)").text
        expected_words_list = ["修改密码","登出"]
        got_list = []
        got_list.append(got_change_psw)
        got_list.append(got_logout)
        CHECK_POINT("验证是否为期待文字", expected_words_list == got_list)

        STEP(2,"点击个人id处右侧的小三角")
        driver.find_element(By.CSS_SELECTOR,".app-main").click()
        time.sleep(2)
        driver.find_element(By.CSS_SELECTOR,".el-icon-caret-bottom").click()
        time.sleep(3)
        got_change_psw2 = driver.find_element(By.CSS_SELECTOR,
        "li.el-dropdown-menu__item:nth-child(1) > span:nth-child(1)").text
        got_logout2 = driver.find_element(By.CSS_SELECTOR,
        "li.el-dropdown-menu__item:nth-child(2) > span:nth-child(1)").text
        got_list2 = []
        got_list2.append(got_change_psw2)
        got_list2.append(got_logout2)
        CHECK_POINT("验证第二次是否为期待文字", expected_words_list == got_list2)
        # li.el - dropdown - menu__item: nth - child(2) > span:nth - child(1)